//
//  OAMeetlistVC.m
//  OA项目
//
//  Created by innofive on 2018/4/17.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "OAMeetlistManagerVC.h"
#import "MainTabBarViewController.h"
#import "MCSwitchTabControl.h"
#import "OAApprovelistCell.h"
#import "OAMeetDetailsVC.h"

@interface OAMeetlistVC()

@end

@implementation OAMeetlistVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

#pragma mark 点击方法
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self onSelectVCForIndexPath:indexPath];
}
-(void)onSelectFooder:(UITapGestureRecognizer *)tapGestureRecognizer
{
    OAApprovelistFooder *fooderView = (OAApprovelistFooder *)[tapGestureRecognizer view];
    
    NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:fooderView.section];
    
    [self onSelectVCForIndexPath:indexPath];
}

-(void)onSelectVCForIndexPath:(NSIndexPath *)indexPath
{
    id model = [self modelForIndexPath:indexPath];
    OAMeetDetailsVC *vc = [[OAMeetDetailsVC alloc]initWithStyle:(UITableViewStylePlain)];
    vc.title = @"会议室审批申请单";
    [self pushToVC:vc model:model];
    
}

@end

@interface OAMeetlist1VC()

@end
@implementation OAMeetlist1VC

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

-(MCHFViewInfo *)tableView:(UITableView *)tableView FooderInSection:(NSInteger)section isBiao:(BOOL)isBiao
{
    return [MCHFViewInfo configForViewId:foodter Class:[BaseTableViewHeaderFooterView class] Height:kFitH(10) TableView:tableView];
}
#pragma mark 点击方法
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self onSelectVCForIndexPath:indexPath];
}
-(void)onSelectFooder:(UITapGestureRecognizer *)tapGestureRecognizer
{
    OAApprovelistFooder *fooderView = (OAApprovelistFooder *)[tapGestureRecognizer view];
    
    NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:fooderView.section];
    
    [self onSelectVCForIndexPath:indexPath];
}

-(void)onSelectVCForIndexPath:(NSIndexPath *)indexPath
{
    id model = [self modelForIndexPath:indexPath];
    OAMeetDetailsVC *vc = [[OAMeetDetailsVC alloc]initWithStyle:(UITableViewStylePlain)];
    vc.title = @"会议室审批申请单";
    [self pushToVC:vc model:model];
    
}
@end

@interface OAMeetlist2VC()

@end

@implementation OAMeetlist2VC

- (void)viewDidLoad {
    [super viewDidLoad];
    
}
-(MCHFViewInfo *)tableView:(UITableView *)tableView FooderInSection:(NSInteger)section isBiao:(BOOL)isBiao
{
    return [MCHFViewInfo configForViewId:foodter Class:[BaseTableViewHeaderFooterView class] Height:kFitH(10) TableView:tableView];
}
#pragma mark 点击方法
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self onSelectVCForIndexPath:indexPath];
}
-(void)onSelectFooder:(UITapGestureRecognizer *)tapGestureRecognizer
{
    OAApprovelistFooder *fooderView = (OAApprovelistFooder *)[tapGestureRecognizer view];
    
    NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:fooderView.section];
    
    [self onSelectVCForIndexPath:indexPath];
}

-(void)onSelectVCForIndexPath:(NSIndexPath *)indexPath
{
    id model = [self modelForIndexPath:indexPath];
    OAMeetDetailsVC *vc = [[OAMeetDetailsVC alloc]initWithStyle:(UITableViewStylePlain)];
    vc.title = @"会议室审批申请单";
    [self pushToVC:vc model:model];
    
}
@end

@interface OAMeetlist3VC()

@end

@implementation OAMeetlist3VC

- (void)viewDidLoad {
    [super viewDidLoad];
    
}
#pragma mark 点击方法
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self onSelectVCForIndexPath:indexPath];
}
-(void)onSelectFooder:(UITapGestureRecognizer *)tapGestureRecognizer
{
    OAApprovelistFooder *fooderView = (OAApprovelistFooder *)[tapGestureRecognizer view];
    
    NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:fooderView.section];
    
    [self onSelectVCForIndexPath:indexPath];
}

-(void)onSelectVCForIndexPath:(NSIndexPath *)indexPath
{
    id model = [self modelForIndexPath:indexPath];
    OAMeetDetailsVC *vc = [[OAMeetDetailsVC alloc]initWithStyle:(UITableViewStylePlain)];
    vc.title = @"会议室审批申请单";
    [self pushToVC:vc model:model];
    
}
@end


@interface OAMeetlistManagerVC ()<panGestureRecognizerDelegate>
@property(nonatomic,strong)MainTabBarViewController *tabBarC;
@property(nonatomic,strong)MCSwitchTabControl *tabControl;

@end

@implementation OAMeetlistManagerVC

- (void)viewDidLoad {
    [super viewDidLoad];
    

    OAMeetlistVC  *vc  = [[OAMeetlistVC alloc]initWithStyle:(UITableViewStyleGrouped)];
    //    vc.view.backgroundColor = [UIColor yellowColor];
    
    OAMeetlist1VC *vc1 = [[OAMeetlist1VC alloc]initWithStyle:(UITableViewStyleGrouped)];
    //    vc1.view.backgroundColor = [UIColor redColor];
    
    OAMeetlist2VC *vc2 = [[OAMeetlist2VC alloc]initWithStyle:(UITableViewStyleGrouped)];
    
    //    vc2.view.backgroundColor = [UIColor brownColor];
    OAMeetlist3VC *vc3 = [[OAMeetlist3VC alloc]initWithStyle:(UITableViewStyleGrouped)];
    
    NSArray *vcs = @[vc,vc1,vc2,vc3];
    MainTabBarViewController *tabBarC = [MainTabBarViewController new];
    tabBarC.panGestureDelegate = self;
    tabBarC.tabBar.hidden = YES;
    tabBarC.viewControllers = vcs;
    [self addChildViewController:tabBarC];
    [self.view addV:tabBarC.view];
    _tabBarC = tabBarC;
}

-(void)onLoadViewByWillAppear:(UIView *)view
{
    MCSwitchTabControl *v = [MCSwitchTabControl new];
    [v addTarget:self action:@selector(onClickChangeBtn:) forControlEvents:UIControlEventValueChanged];
    [v insertSegmentWithTitle:@"待审核" image:nil];
    [v insertSegmentWithTitle:@"已通过" image:nil];
    [v insertSegmentWithTitle:@"已驳回" image:nil];
    [v insertSegmentWithTitle:@"抄送给我" image:nil];
    [view addV:v];
    _tabControl = v;
    WSELF(weakSelf);
    [self onMainQueueAddSub:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        v.frame = CGRectMake(0, 0, size.width,kFitH(45));
        weakSelf.tabBarC.view.frame = CGRectMake(0,kFitH(45),size.width,size.height-kFitH(45));
    }];
}

-(void)onClickChangeBtn:(MCSwitchTabControl *)button
{
    self.tabBarC.selectedIndex = button.selectedSegmentIndex;
    [button segmentLineScrollToIndex:button.selectedSegmentIndex animate:YES];
}

-(void)tabBarViewController:(MainTabBarViewController *)tabBarViewController SelectedIndex:(NSInteger)selectedIndex
{
    _tabControl.selectedSegmentIndex =selectedIndex;
    [_tabControl segmentLineScrollToIndex:selectedIndex animate:YES];
}
@end

